<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 二维码扫码日志表
 */
class CreateWxQrcodeScanlog extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_qrcode_scanlogs', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('日志ID');
            $table->unsignedInteger('qrcode_id')->default(0)->comment('二维码ID');
            $table->unsignedInteger('group_id')->default(0)->comment('分组ID');
            $table->string('from_openid', 40)->default('')->comment('用户openId');
            $table->string('relation_id', 50)->default('')->comment('关联业务主键ID');
            $table->string('event', 50)->default('')->comment('扫码事件');
            $table->string('ticket', 150)->default('')->comment('获取的二维码ticket');
            $table->softDeletes();
            $table->timestamps();
            $table->index(['qrcode_id','group_id','deleted_at'], 'index1');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_qrcode_scanlogs');
    }
}
